//
//  SBAppCallback.m
//  shoubao_user
//
//  Created by xiao_shoubao on 16/9/6.
//  Copyright © 2016年 xiao_shoubao. All rights reserved.
//

#import "AppCallback.h"


@interface AppCallback()/**<WXApiDelegate>*/

@end
@implementation AppCallback

+ (instancetype)diskSbAppCallback {
    
    static AppCallback *sbAppCallback;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        sbAppCallback = [[AppCallback alloc] init];
        
    });
    return sbAppCallback;
    
}

#pragma mark - 配置基本参数
+ (void)basicSetupController {
    

    
    [[UIApplication sharedApplication] setStatusBarHidden:NO ];
    
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    
    [[UINavigationBar appearance] setBarTintColor:kThemeColor];
    
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    
    [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil]];
    [[UITabBar appearance] setTintColor:kThemeColor];
    

    ///微信注册
//    [WXApi registerApp:WX_APIKey];
    

    
}

- (void)dealloc {
    
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)addNSNotificationCenter{
    
    ///抢登录
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccessClick) name:Login_UserRob_Notification object:nil];
    
    ///用户登录
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginOKClick) name:Login_OK_Notification object:nil];
    
    ///用户登出
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginOutClick) name:Login_Out_Notification object:nil];
    
}

///强制退出
- (void)loginSuccessClick{
    
    ///防止重复 跳转
//    UIViewController * vc = [self viewTopViewController];
//    if([vc isMemberOfClass:[LoginViewController class]]){
//        DLog(@"重复跳转登录");
//    }else{
//        
//        [Config updateLogin:NO];
//
//        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
//        LoginViewController *object =  [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
//        object.isPassive = YES; ///被动跳转 填yes
//        
//        UINavigationController *na1 = [[UINavigationController alloc] initWithRootViewController:object];
//        [vc presentViewController:na1 animated:YES completion:nil];
//    }
}

///退出
- (void)loginOutClick {
    
    ///退出
    [Config updateLogin:NO];

}

///登录成功
- (void)loginOKClick{
 
    
}

#pragma mark - 监听网络状态
+ (void)startNetworkMonitoring {
    
    NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 diskCapacity:10 * 1024 * 1024 diskPath:nil];
    [NSURLCache setSharedURLCache:URLCache];
    
    [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
    
    AFNetworkReachabilityManager *afNetworkReachabilityManager = [AFNetworkReachabilityManager sharedManager];
    [afNetworkReachabilityManager startMonitoring]; //开启网络监视器；
    
    [afNetworkReachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        
        switch (status) {
            case AFNetworkReachabilityStatusNotReachable: {
                NSLog(@"当前网络:无网络");
                break;
            }
            case AFNetworkReachabilityStatusReachableViaWiFi: {
                NSLog(@"当前网络:WIFI");
                break;
            }
            case AFNetworkReachabilityStatusReachableViaWWAN: {
                NSLog(@"当前网络:WWAN");
                break;
            }
            default:
                break;
        }
        
    }];
}

@end
